# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=skia-sharp
pkgver=0_git20230912
pkgrel=0
_commit="ced64f6f90cb5349de58e349309d3514cb345c28"
_buildtools_commit="b138e6ce86ae843c42a1a08f37903207bebcca75"
_brotli_commit="6d03dfbedda1615c4cba1211f8d81735575209c8"
_abseil_cpp_commit="cb436cf0142b4cbe47aae94223443df7f82e2920"
_dng_sdk_commit="c8d0c9b1d16bfda56f15165d39e0ffa360a11123"
_egl_registry_commit="a0bca08de07c7d7651047bedc0b653cfaaa4f2ae"
_highway_commit="424360251cdcfc314cfc528f53c872ecd63af0f0"
_imgui_commit="55d35d8387c15bf0cfd71861df67af8cfbda7456"
_libavif_commit="f49462dc93784bf34148715eee36ab6697ca0b35"
_libgav1_commit="0fb779c1e169fe6c229cd1fa9cc6ea6feeb441da"
_libjxl_commit="a205468bc5d3a353fb15dae2398a101dff52f2d3"
_libyuv_commit="d248929c059ff7629a85333699717d7a677d8d96"
_microhttpd_commit="748945ec6f1c67b7efc934ab0808e1d32f2fb98d"
_oboe_commit="b02a12d1dd821118763debec6b83d00a8a0ee419"
_opengl_registry_commit="14b80ebeab022b2c78f84a573f01028c96075553"
_perfetto_commit="93885509be1c9240bc55fa515ceb34811e54a394"
_piex_commit="bb217acdca1cc0c16b704669dd6f91a1b509c406"
_vulkanmemoryallocator_commit="7de5cc00de50e71a3aab22dea52fbb7ff4efceb6"
_vulkan_deps_commit="8a3971e5e9c5cddc437d1cf5e4ac1ed0728d6a49"
_spirv_cross_commit="12542fc6fc05000e04742daf93892a0b10edbe80"
_spirv_headers_commit="bdbfd019be6952fd8fa9bd5606a8798a7530c853"
_spirv_tools_commit="e7c6084fd1d6d6f5ac393e842728d8be309688ca"
_vello_commit="ef2630ad9c647b90863cb0915701d54725733968"
_vulkan_headers_commit="9e61870ecbd32514113b467e0a0c46f60ed222c7"
_vulkan_tools_commit="80b010b1e1b08c1f092fb2bfa337faadf8ea1ba3"
_wuffs_commit="a0041ac0310b3156b963e2f2bea09245f25ec073"
pkgdesc="A complete 2D graphic library for drawing Text, Geometries, and Images"
url="https://github.com/Mis012/skia/tree/with-patches-applied"
arch="x86_64 aarch64"
license="BSD-3-Clause"
makedepends="
	expat-dev
	freetype-dev
	gn
	harfbuzz-dev
	libjpeg-turbo-dev
	libpng-dev
	libwebp-dev
	python3
	zlib-dev
	"
subpackages="$pkgname-dev"
source="$pkgname-$_commit.tar.gz::https://github.com/Mis012/skia/archive/$_commit.tar.gz
	https://github.com/google/brotli/archive/$_brotli_commit/brotli-$_brotli_commit.tar.gz
	https://github.com/abseil/abseil-cpp/archive/$_abseil_cpp_commit/abseil-cpp-$_abseil_cpp_commit.tar.gz
	dng_sdk-$_dng_sdk_commit.tar.gz::https://android.googlesource.com/platform/external/dng_sdk.git/+archive/$_dng_sdk_commit.tar.gz
	https://github.com/KhronosGroup/egl-registry/archive/$_egl_registry_commit/egl-registry-$_egl_registry_commit.tar.gz
	https://github.com/google/highway/archive/$_highway_commit/highway-$_highway_commit.tar.gz
	https://github.com/ocornut/imgui/archive/$_imgui_commit/imgui-$_imgui_commit.tar.gz
	https://github.com/AOMediaCodec/libavif/archive/$_libavif_commit/libavif-$_libavif_commit.tar.gz
	libgav1-$_libgav1_commit.tar.gz::https://chromium.googlesource.com/codecs/libgav1.git/+archive/$_libgav1_commit.tar.gz
	https://gitlab.com/wg1/jpeg-xl/-/archive/$_libjxl_commit/libjxl-$_libjxl_commit.tar.gz
	libyuv-$_libyuv_commit.tar.gz::https://chromium.googlesource.com/libyuv/libyuv.git/+archive/$_libyuv_commit.tar.gz
	microhttpd-$_microhttpd_commit.tar.gz::https://android.googlesource.com/platform/external/libmicrohttpd.git/+archive/$_microhttpd_commit.tar.gz
	https://github.com/google/oboe/archive/$_oboe_commit/oboe-$_oboe_commit.tar.gz
	https://github.com/KhronosGroup/opengl-registry/archive/$_opengl_registry_commit/opengl-registry-$_opengl_registry_commit.tar.gz
	perfetto-$_perfetto_commit.tar.gz::https://android.googlesource.com/platform/external/perfetto.git/+archive/$_perfetto_commit.tar.gz
	piex-$_piex_commit.tar.gz::https://android.googlesource.com/platform/external/piex.git/+archive/$_piex_commit.tar.gz
	https://github.com/GPUOpen-LibrariesAndSDKs/vulkanmemoryallocator/archive/$_vulkanmemoryallocator_commit/vulkanmemoryallocator-$_vulkanmemoryallocator_commit.tar.gz
	vulkan-deps-$_vulkan_deps_commit.tar.gz::https://chromium.googlesource.com/vulkan-deps.git/+archive/$_vulkan_deps_commit.tar.gz
	https://github.com/KhronosGroup/spirv-cross/archive/$_spirv_cross_commit/spirv-cross-$_spirv_cross_commit.tar.gz
	https://github.com/KhronosGroup/spirv-headers/archive/$_spirv_headers_commit/spirv-headers-$_spirv_headers_commit.tar.gz
	https://github.com/KhronosGroup/spirv-tools/archive/$_spirv_tools_commit/spirv-tools-$_spirv_tools_commit.tar.gz
	https://github.com/linebender/vello/archive/$_vello_commit/vello-$_vello_commit.tar.gz
	https://github.com/KhronosGroup/vulkan-headers/archive/$_vulkan_headers_commit/vulkan-headers-$_vulkan_headers_commit.tar.gz
	https://github.com/KhronosGroup/vulkan-tools/archive/$_vulkan_tools_commit/vulkan-tools-$_vulkan_tools_commit.tar.gz
	https://github.com/google/wuffs-mirror-release-c/archive/$_wuffs_commit/wuffs-$_wuffs_commit.tar.gz
	"
# No tests
options="!check"
builddir="$srcdir/skia-$_commit"

case "$CARCH" in
	x86_64) _arch=x64 ;;
	*) _arch="$CARCH" ;;
esac

unpack() {
	local u
	mkdir -p "$srcdir"
	for u in $source; do
		local s="$SRCDEST/$(filename_from_uri $u)"
		local unpackdir
		msg "Unpacking $s..."
		case "$u" in
			*googlesource.com*) unpackdir="$srcdir/$(basename $s .tar.gz)";;
			*) unpackdir="$srcdir";;
		esac
		mkdir -p "$unpackdir"
		tar -C "$unpackdir" -zxf "$s"
	done

}

prepare() {
	default_prepare

	mkdir -p third_party/externals

	mv "$srcdir"/brotli-$_brotli_commit third_party/externals/brotli
	mv "$srcdir"/abseil-cpp-$_abseil_cpp_commit third_party/externals/abseil-cpp
	mv "$srcdir"/dng_sdk-$_dng_sdk_commit third_party/externals/dng_sdk
	mv "$srcdir"/EGL-Registry-$_egl_registry_commit third_party/externals/egl-registry
	mv "$srcdir"/highway-$_highway_commit third_party/externals/highway
	mv "$srcdir"/imgui-$_imgui_commit third_party/externals/imgui
	mv "$srcdir"/libavif-$_libavif_commit third_party/externals/libavif
	mv "$srcdir"/libgav1-$_libgav1_commit third_party/externals/libgav1
	mv "$srcdir"/jpeg-xl-$_libjxl_commit third_party/externals/libjxl
	mv "$srcdir"/libyuv-$_libyuv_commit third_party/externals/libyuv
	mv "$srcdir"/microhttpd-$_microhttpd_commit third_party/externals/microhttpd
	mv "$srcdir"/oboe-$_oboe_commit third_party/externals/oboe
	mv "$srcdir"/OpenGL-Registry-$_opengl_registry_commit third_party/externals/opengl-registry
	mv "$srcdir"/perfetto-$_perfetto_commit third_party/externals/perfetto
	mv "$srcdir"/piex-$_piex_commit third_party/externals/piex
	mv "$srcdir"/VulkanMemoryAllocator-$_vulkanmemoryallocator_commit third_party/externals/vulkanmemoryallocator
	mv "$srcdir"/vulkan-deps-$_vulkan_deps_commit third_party/externals/vulkan-deps
	mv "$srcdir"/SPIRV-Cross-$_spirv_cross_commit third_party/externals/spirv-cross
	mv "$srcdir"/SPIRV-Headers-$_spirv_headers_commit third_party/externals/spirv-headers
	mv "$srcdir"/SPIRV-Tools-$_spirv_tools_commit third_party/externals/spirv-tools
	mv "$srcdir"/vello-$_vello_commit third_party/externals/vello
	mv "$srcdir"/Vulkan-Headers-$_vulkan_headers_commit third_party/externals/vulkan-headers
	mv "$srcdir"/Vulkan-Tools-$_vulkan_tools_commit third_party/externals/vulkan-tools
	mv "$srcdir"/wuffs-mirror-release-c-$_wuffs_commit third_party/externals/wuffs
}

build() {
	# Keep this list unindented, gn really doesn't like tabs for indentation
	gn gen "out/linux/$_arch" --args="
is_official_build=true
skia_enable_tools=false
target_os=\"linux\"
target_cpu=\"$_arch\"
skia_use_icu=false
skia_use_sfntly=false
skia_use_piex=true
skia_use_system_harfbuzz=true
skia_use_system_expat=true
skia_use_system_freetype2=true
skia_use_system_libjpeg_turbo=true
skia_use_system_libpng=true
skia_use_system_libwebp=true
skia_use_system_zlib=true
skia_enable_gpu=true
extra_cflags=[ \"-DSKIA_C_DLL\", \"-fpermissive\" ]
linux_soname_version=\"99.9\""
	ninja -C "out/linux/$_arch" 'SkiaSharp'
}

package() {
	install -Dm755 out/linux/$_arch/libSkiaSharp.so.99.9 "$pkgdir"/usr/lib/libSkiaSharp.so.99.9
	ln -s /usr/lib/libSkiaSharp.so.99.9 "$pkgdir"/usr/lib/libSkiaSharp.so
}

sha512sums="
05ae5f783e4190daaf7b7cc19ea36f8d7235238c1f06afb5109c3892801f1634e6da5a00fbca4974719f3ef5758d1e8ad8da641e09baf266aa9ac72f12d3787b  skia-sharp-ced64f6f90cb5349de58e349309d3514cb345c28.tar.gz
9a6ae22a85bcd20b9a1b6c4d51bddc76e9e7461f2e1e144fb0625ed67e6a1c4ea635a75ba8f07b3914bab8de1d319e4c13c815989ca1691ba0215197c385eb08  brotli-6d03dfbedda1615c4cba1211f8d81735575209c8.tar.gz
765b542bd7c9cf2c8d0f150aaeaae6bb12d4643d314f5b4026139a63b4f2852ae8774bb740f3c8602ab2b49646e194151a344f03237313ab69251dfd931f9874  abseil-cpp-cb436cf0142b4cbe47aae94223443df7f82e2920.tar.gz
71ff48fe6d18685d7937f0314dcf373d50d9413dd15453c4b04ed11ee06340cc085444d06db6f2161830c2f874c5a0a89d53b0fae4ba5c5e4084072165a97a49  dng_sdk-c8d0c9b1d16bfda56f15165d39e0ffa360a11123.tar.gz
f07ed88d9b2e73eeb6ff82a811d7fad5d68bebf0a9ccc6c6df7678687b9a769e7be2efe8143be5c97bdbb7666ce76965a260335daa5ae07992c20e309b3b1cef  egl-registry-a0bca08de07c7d7651047bedc0b653cfaaa4f2ae.tar.gz
c9ace7124b56307e47c9d220d9cb5aed698509245cc0502f7fa1d8df14c61aaf0a2ef442ce36576193953bb7e39df214ad72e1cbc720d121920bec9e430a3d50  highway-424360251cdcfc314cfc528f53c872ecd63af0f0.tar.gz
8075f78d06ac5cbc0ebc525fc070fe323306d4798d02cbce0b6610da4afb11a12a6e242bb818af7b3efcfc97262d2e6b638fef65cf974698448992872e47e692  imgui-55d35d8387c15bf0cfd71861df67af8cfbda7456.tar.gz
463640fc5868f8d1201a17be5ddb61c65b1ea3513e19093aa1b678281cae4fae873b50a05a7e57846e640c3fe1fd0d297a712dc92f6c4697e98464ca7c675a58  libavif-f49462dc93784bf34148715eee36ab6697ca0b35.tar.gz
6964a6be9eecf06ac67e56f3b2e88aade18335140c53726f3385161d279d2dcc96bfb5bff8e9e77858326e2ce26bec2e21682ab46ad001a6e1f789bb373a7ee3  libgav1-0fb779c1e169fe6c229cd1fa9cc6ea6feeb441da.tar.gz
0ec9b93c6c2c82538b768c167e591cb7db5b0557f484fffc6b3c4a2eeff05c97e6278002ae83fb021dda26a75904fc65a21c006675ebbf9836c1379d45ac6280  libjxl-a205468bc5d3a353fb15dae2398a101dff52f2d3.tar.gz
6085a21c2b6c428166a4fe030ac05cde79d1f39f16f15267a58c639bf8e23f95e8380f73dcb7714ec0a2002db348b9af3b4a5ca783f5b4a5db5f7aeb66abcd2e  libyuv-d248929c059ff7629a85333699717d7a677d8d96.tar.gz
e3ed6de28fc27f7fae01d0f39a95817246be7658e2233e2b8c7933bec834a48508cddd445fa881755c064e8e3e0ae00d9b9c169382b904e8e19c8a2f8597a5f5  microhttpd-748945ec6f1c67b7efc934ab0808e1d32f2fb98d.tar.gz
fd99870179bef97db6d0007652505e1555cdb14f4cad1c582e449cc3b61cdaf5a3de395e9569d6d367927a16aad6a277771db223a99f14192d56b3fa30615c30  oboe-b02a12d1dd821118763debec6b83d00a8a0ee419.tar.gz
6f7bde922561aa495d93ec274009724feaeb3e03e619adfaa7ce520e5d11a83f93462ccc2f2e9c4aa387ace61912196a1ecfd90cdc5672f088ba1b0c3e62b53d  opengl-registry-14b80ebeab022b2c78f84a573f01028c96075553.tar.gz
a903210bf29bf1d15c54e69cd6734a0b4983cba8629a0ac2229270fe67765fb21cc94008ba6f8f865106007dc7923cf7b937b654113dbac92d1850760c3f571f  perfetto-93885509be1c9240bc55fa515ceb34811e54a394.tar.gz
5920bd7a0c1e9bc2d4e231b92587910b30022d5d35e3b0c64c057c2eff49d9f9f380a4f3a733a9f4833d38ffd2d9d0dc559502df5e14df720f2b6453a5e0f42a  piex-bb217acdca1cc0c16b704669dd6f91a1b509c406.tar.gz
185c3964f9d0f46a3fb30637c4b83ce1015efcc1bca62b6ed0fdbf67d4c72ede792ba71411552a183d9bc4f74c72ecc1dc78941300594d4a5bac9dcdc2661c30  vulkanmemoryallocator-7de5cc00de50e71a3aab22dea52fbb7ff4efceb6.tar.gz
bcf10b8a4dc9bcbf066e0d198e89bd4c67c0640ba69bb06aedeb27de468011eb7ab4656d2d93749f22f9221eb6a71938bf59c084cb88c4b39aa6d0f584c9043f  vulkan-deps-8a3971e5e9c5cddc437d1cf5e4ac1ed0728d6a49.tar.gz
2112eda633b08dd6a6d17ad54d299a301e7b0d3a0c8f27e7073eb98c4ba5c9375fe60cc838b263daf4ad535533192acbcd28a30860cdf99849834b3e6a421b19  spirv-cross-12542fc6fc05000e04742daf93892a0b10edbe80.tar.gz
95a11bb56ffcad5faff738d58d9c7cbb146462268e5a7a8ba4e19fb18c35f881f59bd35354d46ae7569f41b9f3eebe44add0f62f6f607d7a8db0edb80ec79241  spirv-headers-bdbfd019be6952fd8fa9bd5606a8798a7530c853.tar.gz
c8bcba6e3d913a8b6004f121bb505bed1f4ecba3fcf0eeb29507c8f0a5d4995f38e75194f1ff9721cf254530d7f88356c79055e478dcca2d145513a29866c68c  spirv-tools-e7c6084fd1d6d6f5ac393e842728d8be309688ca.tar.gz
b599c509f624546d18143c0058402c678f6db5fd0436940a4ed0fe609e93552a0426ad7112bcf8bc5a55f25b68cf94dde66c6aa5c66515cecb85cd5a387902a1  vello-ef2630ad9c647b90863cb0915701d54725733968.tar.gz
d627cb32bbd4b8886c7eb92686156f6c79e4d40cba2b9e05583241853b153ea6456fc567635f14cf8a70a9e153a9f288516c06b7194b52151d552d9122c4e694  vulkan-headers-9e61870ecbd32514113b467e0a0c46f60ed222c7.tar.gz
d4cd1b1d78023df2fc31f18a277b22714850eb7639c0a5525e123316060691ac3b7a48c7a04141cec79f5df0a82c24b4f2bcb7d67a36e48195f01ba6efd8d1eb  vulkan-tools-80b010b1e1b08c1f092fb2bfa337faadf8ea1ba3.tar.gz
6b72af9439d2acf7052f23d87588a027b457a04ba99d1573de1f9f85898607a01832cabbd5b8ddf5f5e91eaa5757933181e03dbf2aa6679f514b99889a019b45  wuffs-a0041ac0310b3156b963e2f2bea09245f25ec073.tar.gz
"
